package xmldatabase;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

/**
 *
 * @author betty
 */
public class Deleteuser {

    private Connection conn;
    // 传递sql语句
    private Statement stt = null;

    ResultSet rs;

    public void delete(Integer id) throws SQLException {
        conn = DBConnection.getConnection();
        stt = conn.createStatement();
        if (conn == null) {
            return;
        }
        String sql = "delete from news where id=?";
        // 预处理sql语句
        PreparedStatement presta = conn.prepareStatement(sql);
        // 设置sql语句中的values值
        presta.setInt(1, id);
        // 执行SQL语句，实现数据添加
        presta.execute();

    }
}
